from pydantic_settings import BaseSettings
from typing import List
import os

class Settings(BaseSettings):
    # Application Configuration
    APP_NAME: str = "Crawl4AI Task Manager"
    VERSION: str = "1.0.0"
    DEBUG: bool = False
    HOST: str = "0.0.0.0"
    PORT: int = 8000
    
    # Security Configuration
    SECRET_KEY: str = "your-secret-key-here"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    REFRESH_TOKEN_EXPIRE_DAYS: int = 7
    ALLOWED_ORIGINS: List[str] = ["http://localhost:3000", "http://localhost:8501"]
    ALLOWED_HOSTS: List[str] = ["localhost", "127.0.0.1"]
    
    # Storage Configuration (JSON Files)
    DATA_DIR: str = "data"
    
    # Crawl4AI Configuration
    CRAWL4AI_API_URL: str = "https://api.crawl4ai.com"
    CRAWL4AI_API_KEY: str = "your-crawl4ai-api-key"
    CRAWL4AI_TIMEOUT: int = 300
    
    # Task Configuration
    MAX_CONCURRENT_TASKS: int = 10
    DEFAULT_TASK_TIMEOUT: int = 3600
    MAX_RETRY_ATTEMPTS: int = 3
    
    # Logging Configuration
    LOG_LEVEL: str = "INFO"
    LOG_FILE: str = "logs/app.log"
    LOG_ROTATION: str = "1 day"
    LOG_RETENTION: str = "30 days"
    
    class Config:
        env_file = ".env"
        case_sensitive = True

# Create global settings instance
settings = Settings()
